/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       rendertexture.h
 * Author:     twoja stara
 * Created on: 2009-09-15
 *
 **********************************************************************************************************************/

#ifndef RENDERTEXTURE_H_
#define RENDERTEXTURE_H_

#include "texture.h"
#include "rendertarget.h"

namespace mGameEngine
{
namespace Graphics
{

/**
 * Render texture.
 * Class used for rendering scene (or only some parts) into textures.
 * Such texture can be used the same way as normal textures.
 */
class RenderTexture : public RenderTarget, public Texture
{
private:
    /**
     * Initialize render texture.
     */
    void _init();

protected:
    /**
     * Framebuffer id.
     */
    uint _fboId;

    /**
     * Renderbuffer id.
     */
    uint _rboId;

public:
    /**
     * Create render texture.
     */
    RenderTexture();

    /**
     * Create render texture with specified size.
     * @param size render texture size.
     * @param wrap wrapping mode.
     * @param filter filtering mode.
     */
    RenderTexture(const Vector2 &size,
                    TextureWrapping wrap = TEX_WRAP_CLAMP,
                    TextureFiltering filter = TEX_FILTER_NEAREST);

    /**
     * Destroy render texture.
     */
    virtual ~RenderTexture();

    /**
     * Set render texture size.
     * @param size size.
     */
    virtual void setSize(const Vector2 &size);

    /**
     * Begin rendering to texture.
     */
    virtual void beginRendering();

    /**
     * End rendering to texture.
     */
    virtual void endRendering();
};

}
}

#endif // RENDERTEXTURE_H_
